# test.py
from answer import complete_answer
import time
from typing import List

def run_stream_test(cues: List[str]):
    print(f"\n测试问题: {cues[0]}")
    print(f"关键词: {cues[1:] if len(cues) > 1 else '无'}")
    print("流式输出:")
    
    try:
        start_time = time.time()
        first_chunk = True
        
        for chunk in complete_answer(cues):
            if first_chunk:
                print(f"\n首字延迟: {time.time()-start_time:.2f}s")
                first_chunk = False
            print(chunk, end='', flush=True)
            
        print(f"\n总耗时: {time.time()-start_time:.2f}s")
    except Exception as e:
        print(f"错误: {str(e)}")

if __name__ == '__main__':
    test_cases = [
        ["诸葛亮为什么用空城计", "司马懿", "西城"]
    ]
    
    for cues in test_cases:
        run_stream_test(cues)
        time.sleep(1)  # 请求间隔